//
//  YuserHeaderView.swift
//  Three-SinaWeibo
//
//  Created by 李旭阳 on 15/11/17.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

let StatusCellMargin: CGFloat = 10
let StatusCellIconWidth: CGFloat = 35

class YuserHeaderView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置UI
    private func setupUI(){
        backgroundColor = UIColor(white: 0.95, alpha: 1)
        addSubview(iconImage)
        addSubview(nameLabel)
        addSubview(memberIconView)
        addSubview(verifiedIconView)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(contentLabel)
        //设置约束
        iconImage.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top).offset(StatusCellMargin)
            make.left.equalTo(snp_left).offset(StatusCellMargin)
            make.height.equalTo(StatusCellIconWidth)
            make.width.equalTo(StatusCellIconWidth)
        }
        nameLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(iconImage.snp_top)
            make.left.equalTo(iconImage.snp_right).offset(StatusCellMargin)
        }
        
        memberIconView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(nameLabel.snp_top)
            make.left.equalTo(nameLabel.snp_right).offset(StatusCellMargin)
        }
        
        verifiedIconView.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(iconImage.snp_right)
            make.centerY.equalTo(iconImage.snp_bottom)
        }
        
        timeLabel.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(iconImage.snp_bottom)
            make.left.equalTo(iconImage.snp_right).offset(StatusCellMargin)
        }
        
        
        sourceLabel.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(timeLabel.snp_bottom)
            make.left.equalTo(timeLabel.snp_right).offset(StatusCellMargin)
        }
        
        contentLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(iconImage.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(iconImage)
        }
        
    }
    
    //MARK: 懒加载 UI控件
    private lazy var iconImage: UIImageView = UIImageView (image: UIImage(named: "avatar_default_big"))
    private lazy var nameLabel: UILabel = UILabel (title: "模拟微博", size: 16, color: UIColor.darkGrayColor())
    private lazy var verifiedIconView: UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    private lazy var memberIconView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    private lazy var timeLabel: UILabel = UILabel(title: "22:22", size: 10, color: UIColor.orangeColor())
    private lazy var sourceLabel: UILabel = UILabel (title: "来自:微博项目", size: 10, color: UIColor.lightGrayColor())
    private lazy var contentLabel: UILabel = UILabel(title: "怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办怎么办", size: 14, color: UIColor.lightGrayColor(),margin: StatusCellMargin)
}
